// pages/personal/mdcubs/mdcubs.js
const { getApplicationList, changeApplication } = require('../../../api/personal')
import Dialog from '../../miniprogram_npm/@vant/weapp/dialog/dialog';
import Toast from '../../../miniprogram_npm/@vant/weapp/toast/toast';
let app =  getApp();

Page({
  data:{
    // 导航头组件所需的参数
    nvabarData: {
      showCapsule: 1, //是否显示左上角图标   1表示显示    0表示不显示
      title: '', //导航栏 中间的标题
      white: false,
      bgColor:'#B7EADE'
    },
    // 导航头的高度
    height: app.globalData.height * 2,
    applicationList:[],
    handleState:''
  },
  onLoad(){
    let that = this
    getApplicationList.request()
      .then(res=>{
        console.log(res)
        let { List } = res
        that.setData({applicationList:List})
      })
  },
  delete(e){
    let that = this
    Dialog.confirm({
      title: '提示',
      message: '是否确定拒绝申请'
    })
    .then(() => {
      that.handleFun(e,2)
    })
    .catch(() =>{
    
    })
  },
  arrow(e){
    this.handleFun(e,1)
  },
  handleFun(e,state){
    let that = this
    let id = e.currentTarget.dataset.id
    let list = this.data.applicationList

    changeApplication({id,State:state})
      .then(res=>{
        const { State } = res
      })
      .then(()=>{
        getApplicationList.request()
        .then(res=>{
          console.log(res)
          let { List } = res
          that.setData({applicationList:List})
        })
      })
  }
})